<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="ISO-8859-1"%>
<%@ page import = "quiz.Quiz" %>
<%@ page import = "quiz.Question" %>
<%@ page import = "quiz.Answer" %>
<%@ page import = "java.util.ArrayList" %>
<%
	Quiz q = (Quiz)request.getAttribute("quiz");
	String name = "Add Questions to "+q.getName();
%>
<jsp:include page="templates/header.jsp" flush="true">
	<jsp:param value = "Add Questions | Quizzard" name = "title" />
</jsp:include>
<jsp:include page="templates/title_bar.jsp" flush = "true">
	<jsp:param value = "<%=name%>" name = "title" />
</jsp:include>
<div id = "content">
<div class = "center">
<%
	String error = (String)request.getAttribute("error");
	if (error != null) {
		out.println("<div id = 'error'>"+error+"</div>");
	}
%>
<div class = "section_title bottom_border question_expanded"><%= q.getName() %> <a href = "ShowSelectedQuiz?id=<%= q.getID() %>"><span class = "btn">Finish Quiz!</span></a>
</div>
<%
	for (Question question: q.getQuestions()) {
		ArrayList<Answer> answers = question.getAnswers();
		
		out.print("<div class = \"bottom_border question_expanded\"><div class = \"section_title_small\">"+question.getContent()+"</div><div class = \"correct_answer\">Correct answer(s)");
		for (Answer a: answers) {
			if (a.isCorrect()) out.println(": "+a.getContent());
		}
		out.println("</div></div>");
	}
%>
<form method = "post" action = "AddQuestion">
Add new <select name = "type"><option value = "<%= Question.FITB %>">Fill in the Blank</option><option value = "<%= Question.MC %>">Multiple Choice</option><option value = "<%= Question.PICTURE %>">Picture</option><option value = "<%= Question.QR %>">Free response</option></select> question with <input type = "text" name = "numberAnswers" value = "0" /> possible answers.
<input type = "hidden" name = "quizID" value = "<%= q.getID() %>" />
<input type = "submit" value = "Go" class = "btn"/>
</form>
</div>
</div>
<jsp:include page="templates/footer.jsp" flush="true" />